package com.oak.broke.config;

import org.springframework.context.annotation.Bean;
import org.springframework.data.redis.connection.RedisConnectionFactory;
import org.springframework.data.redis.core.RedisTemplate;
import org.springframework.data.redis.serializer.Jackson2JsonRedisSerializer;
import org.springframework.stereotype.Component;

/**
 * @author tanghan
 * @Description redis配置
 * @date 2023/04/13/ 17:44:00
 */
@Component
public class RedisConfig {

    /**
     * redis配置
     *
     * @param redisConnectionFactory redis
     * @return
     */
    @Bean
    public RedisTemplate<Object, Object> serializerDomainRedisTemplate(RedisConnectionFactory redisConnectionFactory) {
        RedisTemplate<Object, Object> redisTemplate = new RedisTemplate<>();
        redisTemplate.setConnectionFactory(redisConnectionFactory);
        Jackson2JsonRedisSerializer<Object> ser = new Jackson2JsonRedisSerializer<>(Object.class);
        redisTemplate.setDefaultSerializer(ser);
        return redisTemplate;
    }
}
